import React, { memo, useMemo } from 'react';

import { TreeSelect } from 'antd';
import { covertTreeData } from '../../utils/common';

const MenuSelector = ({ value, onChange, treeData }) => {
  const tree = useMemo(() => {
    return [
      {
        value: 0,
        title: '根',
        key: 0,
        children: covertTreeData(treeData),
      },
    ];
  }, [treeData]);

  return <TreeSelect onChange={onChange} value={value} treeData={tree} />;
};

export default memo(MenuSelector);
